package com.example.gulimall.common.utils;




import com.example.gulimall.common.enums.ServiceCodeEnum;

import java.util.Map;

/**
 * <p>DESC: 统一返回辅助</p>
 * <p>DATE: 2019/1/30</p>
 * <p>VERSION:1.0.0</p>
 * <p>@AUTHOR: JGD</p>
 */
public class ResponseHelper<T> {

    public static <T> JsonResultVO<T> createJsonResult(ServiceCodeEnum serviceCodeEnum) {
        return new JsonResultVO<>(serviceCodeEnum.getCode(), serviceCodeEnum.getMessage());
    }

    public static <T> JsonResultVO<T> createJsonResult(ServiceCodeEnum serviceCodeEnum, T data) {
        return new JsonResultVO<>(serviceCodeEnum.getCode(), serviceCodeEnum.getMessage(), data);
    }

    public static JsonResultVO<Map<String, String>> createJsonResult(Map<String, String> map) {
        return new JsonResultVO<>(map);
    }

    public static <T> JsonResultVO<T> createJsonResult() {
        return new JsonResultVO<>();
    }

    public static <T> JsonResultVO<T> createJsonResult(Integer code, String message) {
        return new JsonResultVO<>(code, message);
    }

    public static <T> JsonResultVO<T> createJsonResult(Integer code, String message, T data) {
        return new JsonResultVO<>(code, message, data);
    }

    public static <T> JsonResultVO<T> createJsonResult(T obj) {
        return new JsonResultVO<T>(obj);
    }

}
